package edu.towson.cosc603.coffeemaker;

import static org.junit.Assert.*;
import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

public class InventoryTest extends TestCase{

	private Inventory iv;
	private Recipe r1;

	@Before
	public void setUp() throws Exception {
		iv = new Inventory();

		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(1);
	}

	@Test
	public void testSetCoffee1() {
		assertEquals(15, iv.getCoffee());
		iv.setCoffee(-1);
		assertEquals(0, iv.getCoffee());
	}

	@Test
	public void testSetMilk1() {
		assertEquals(15, iv.getMilk());
		iv.setMilk(-1);
		assertEquals(0, iv.getMilk());
	}

	@Test
	public void testSetSugar1() {
		assertEquals(15, iv.getSugar());
		iv.setSugar(-1);
		assertEquals(0, iv.getSugar());
	}

	@Test
	public void testSetChocolate1() {
		assertEquals(15, iv.getChocolate());
		iv.setChocolate(-1);
		assertEquals(0, iv.getChocolate());
	}

	@Test
	public void testEnoughIngredients1() {
		assertTrue(iv.enoughIngredients(r1));

		iv.setCoffee(1);
		assertFalse(iv.enoughIngredients(r1));

		iv.setCoffee(15);
		iv.setMilk(0);
		assertFalse(iv.enoughIngredients(r1));

		iv.setMilk(15);
		iv.setSugar(0);
		assertFalse(iv.enoughIngredients(r1));

		iv.setSugar(15);
		iv.setChocolate(0);
		assertFalse(iv.enoughIngredients(r1));
	}

	@Test
	public void testToString1() {
		assertEquals("Coffee: 15\nMilk: 15\nSugar: 15\nChocolate: 15\n",
				iv.toString());
	}
}